package calao.client.ui;

import calao.client.util.DayTime;

import com.google.gwt.user.client.ui.TextBox;

public class DayTimeBox
extends TextBox
implements Validatable
{
		
	public void validate() 
	throws InvalidInputException 
	{
		try {
			DayTime.parse(getText());
			removeStyleName(Styles.INVALID);
		}
		catch (Exception e) {
			addStyleName(Styles.INVALID);
			throw new InvalidInputException();
		}
	}	
	
	public DayTime getTime()
	{
		return DayTime.parse(getText());
	}

	public void setTime(int hours, int minutes)
	{
		setTime(new DayTime(hours, minutes));
	}
	
	public void setTime(DayTime time)
	{
		setText(time.toString());
	}

}
